/*
 * test.cpp
 *
 *  Created on: Jul 5, 2012
 *      Author: plasmayang
 */
#include "datafile.h"

#include <iostream>

#include "Fileobj.h"
#include "DataObj.h"
#include "DataObj.cpp"//template used, including this file makes compiler work properly
using namespace std;
using dataobject::DataObj;


int main() {


	int dim = 2;
	hsize_t * size = new hsize_t[dim];
	size[0] = 20;
	size[1]=10;

	typedef double * doublep;
	DataObj< double > a(H5T_NATIVE_DOUBLE);

	//doublep * p = new doublep[size[0]];
	//for (int idx = 0; idx < size[0]; idx ++)
		//p[idx] = new double[size[1]];

	double aa[size[0]][size[1]];
	for (hsize_t idx = 0; idx < size[0]; idx ++)
		for (hsize_t idy = 0; idy < size[1]; idy ++){
			//p[idx][idy] = 1.2*idx+3 +1.5*idy;
			aa[idx][idy] = 1.2*idx+3 +1.5*idy;}
	doublep pp = &(aa[0][0]);
	string dataname = "firstdata";
	a.setData(pp);
	a.setName(dataname);
	a.setEvolveFlag(evolveflag::given);
	a.setDim(dim,size);

//	cout<<a.getDim()<<a.getEvolveFlag()<<a.getName()<<a.get_element_type()<<endl;
	//a.show();
	string filename = "test.nc";

	Fileobj file(filename,file_format::netcdf,1);

	a.sendto(file,dataname);


	return 0;

}
